<?php

$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';

$config = [
    'id' => 'basic-console',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log','print_queue','subscribe_queue','count_queue','auto_accept_queue','refund_queue','websocket_queue'],
    'controllerNamespace' => 'app\commands',
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
        '@tests' => '@app/tests',
    ],
    'components' => [
        'print_queue' => require __DIR__ . '/queue/task/print_queue.php',
        'subscribe_queue' => require __DIR__ . '/queue/task/subscribe_queue.php',
        'count_queue' => require __DIR__ . '/queue/task/count_queue.php',
        'auto_accept_queue' => require __DIR__ . '/queue/task/auto_accept_queue.php',
        'refund_queue' => require __DIR__ . '/queue/task/refund_queue.php',
        'websocket_queue' => require __DIR__ . '/queue/task/websocket_queue.php',
        'wechat' => [
            'class' => 'jianyan\easywechat\Wechat',
            'userOptions' => [],  // 用户身份类参数
            'sessionParam' => 'wechatUser', // 微信用户信息将存储在会话在这个密钥
            'returnUrlParam' => '_wechatReturnUrl', // returnUrl 存储在会话中
            'rebinds' => [ // 自定义服务模块
                // 'cache' => 'common\components\Cache',
            ]
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'flushInterval'=>1,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'logFile'=>'@runtime/logs/cli_error.log'
                ],
            ],
        ],
        'db' => $db,
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'generators'=>[
            'queue'=>[
                'class'=>'yii\queue\gii\Generator'
            ]
        ],
    ];
}

return $config;
